<?php

namespace Acme\DemoBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
use Symfony\Component\Security\Core\User\UserInterface;
/**
 * Acme\DemoBundle\Entity\Utilisateurs
 *
 * @ORM\Table()
 * @ORM\Entity(repositoryClass="Acme\DemoBundle\Entity\UtilisateursRepository")
 */
class Utilisateurs implements UserInterface
{
    /**
     * @var integer $id
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

    /**
     * @var string $nom
     *
     * @ORM\Column(name="nom", type="string", length=145)
     */
    private $nom;

    /**
     * @var string $prenoms
     *
     * @ORM\Column(name="prenoms", type="string", length=145)
     */
    private $prenoms;

    /**
     * @var string $mail
     *
     * @ORM\Column(name="mail", type="string", length=255)
     */
    private $mail;

    /**
     * @var string $pass
     *
     * @ORM\Column(name="pass", type="string", length=45)
     */
    private $pass;

    /**
     * @var datetime $create_at
     *
     * @ORM\Column(name="create_at", type="datetime")
     */
    private $create_at;

    /**
     * @var smallint $statut
     *
     * @ORM\Column(name="statut", type="smallint")
     */
    private $statut;
    
    /**
     * @ORM\ManyToMany(targetEntity="Projets", mappedBy="utilisateurs")
     */
    protected $projets;
    
     /**
     * @ORM\OneToMany(targetEntity="ProjetsAnnuaires",mappedBy="utilisateurs")
     */
    protected $projetsAnnuaires; 
    
    /**
    * @ORM\ManyToOne(targetEntity="Roles", inversedBy="utilisateurs")
    * @ORM\JoinColumn(name="roles_id", referencedColumnName="id")
    */
    protected $roles;
    
    /**
     * @var string $salt
     *
     * @ORM\Column(name="salt", type="string", length=255)
     */
    private $salt;
    
    public function __construct()
    {
        $this->projets = new ArrayCollection();
    }

    /**
     * Get id
     *
     * @return integer 
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set nom
     *
     * @param string $nom
     */
    public function setNom($nom)
    {
        $this->nom = $nom;
    }

    /**
     * Get nom
     *
     * @return string 
     */
    public function getNom()
    {
        return $this->nom;
    }

    /**
     * Set prenoms
     *
     * @param string $prenoms
     */
    public function setPrenoms($prenoms)
    {
        $this->prenoms = $prenoms;
    }

    /**
     * Get prenoms
     *
     * @return string 
     */
    public function getPrenoms()
    {
        return $this->prenoms;
    }

    /**
     * Set mail
     *
     * @param string $mail
     */
    public function setMail($mail)
    {
        $this->mail = $mail;
    }

    /**
     * Get mail
     *
     * @return string 
     */
    public function getMail()
    {
        return $this->mail;
    }

    /**
     * Set pass
     *
     * @param string $pass
     */
    public function setPass($pass)
    {
        $this->pass = $pass;
    }

    /**
     * Get pass
     *
     * @return string 
     */
    public function getPass()
    {
        return $this->pass;
    }

    /**
     * Set create_at
     *
     * @param datetime $createAt
     */
    public function setCreateAt($createAt)
    {
        $this->create_at = $createAt;
    }

    /**
     * Get create_at
     *
     * @return datetime 
     */
    public function getCreateAt()
    {
        return $this->create_at;
    }

    /**
     * Set statut
     *
     * @param smallint $statut
     */
    public function setStatut($statut)
    {
        $this->statut = $statut;
    }

    /**
     * Get statut
     *
     * @return smallint 
     */
    public function getStatut()
    {
        return $this->statut;
    }

    /**
     * Add projets
     *
     * @param Acme\DemoBundle\Entity\Projets $projets
     */
    public function addProjets(\Acme\DemoBundle\Entity\Projets $projets)
    {
        $this->projets[] = $projets;
    }

    /**
     * Get projets
     *
     * @return Doctrine\Common\Collections\Collection 
     */
    public function getProjets()
    {
        return $this->projets;
    }

    /**
     * Add projetsAnnuaires
     *
     * @param Acme\DemoBundle\Entity\ProjetsAnnuaires $projetsAnnuaires
     */
    public function addProjetsAnnuaires(\Acme\DemoBundle\Entity\ProjetsAnnuaires $projetsAnnuaires)
    {
        $this->projetsAnnuaires[] = $projetsAnnuaires;
    }

    /**
     * Get projetsAnnuaires
     *
     * @return Doctrine\Common\Collections\Collection 
     */
    public function getProjetsAnnuaires()
    {
        return $this->projetsAnnuaires;
    }

    public function equals(UserInterface $user) {
        return ($this->getUsername()== $user->getUsername());
    }

    public function eraseCredentials() {
        
    }

    public function getPassword() {
        $this->getPass();
    }

    public function getRoles() {
         return $this->roles;
    }

    public function  setSalt($salt){
        $this->salt = $salt;
    }


    public function getSalt() {
        return $this->salt;
    }

    public function getUsername() {
       $this->getMail();
    }

    /**
     * Set roles
     *
     * @param Acme\DemoBundle\Entity\Roles $roles
     */
    public function setRoles(\Acme\DemoBundle\Entity\Roles $roles)
    {
        $this->roles = $roles;
    }
}